﻿using Extend.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Extend.ViewModels
{
    class MainPageViewModel: Common.BindableBase
    {
        public MainPageViewModel()
        {
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                this.Value = "design-value";
                this.Result = "design-result";
            }
        }

        string _Value = default(string);
        public string Value { get { return _Value; } set { SetProperty(ref _Value, value); } }

        string _Result = default(string);
        public string Result { get { return _Result; } set { SetProperty(ref _Result, value); } }

        DelegateCommand _DoCommand = null;
        public DelegateCommand DoCommand
        {
            get
            {
                if (_DoCommand != null)
                    return _DoCommand;
                _DoCommand = new DelegateCommand
                (
                    () => { this.Result = string.Format("{0}, thank you", this.Value); },
                    () => { return true; }
                );
                this.PropertyChanged += (s, e) => _DoCommand.RaiseCanExecuteChanged();
                return _DoCommand;
            }
        }
    }
}
